﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PurchaseOrderCtrl.ascx.cs" Inherits="WebUI.Controls.PurchaseOrderCtrl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/Controls/POSControls/PurchaseOrderDetailsCtrl.ascx" TagName="PurchaseOrderDetails" TagPrefix="uc" %>
<script type="text/javascript">
    function onEditProduct() {
        var id = getSelectedItemID<%=purchaseOrderDetails.ClientID %>();
        if(id == null){
            alert("No item was selected!");
            return false;
        }
        var returnValue = window.showModalDialog('<%=GetOrderDetailsEditPageLink() %>' + '&mode=edit&id=' + id, '', 'dialogWidth=500px;dialogHeight=400px;resizable=no;help=no;unadorned=yes;');
        return returnValue > 0;
    }

    function onRemoveProduct() {
        return confirm("This action will delete all checked items. Do you want to continue?");
    }
    
    function onDiscountLostFocus(txt){        
        var qty = txt.value;
        if (qty == '') qty = 0;

        txt.value = qty;
    }
    
    function showPrintDlg(key) {
        var returnValue = window.showModalDialog(key, '', 'dialogWidth=800px;dialogHeight=600px;resizable=yes;help=no;unadorned=yes;');
    }
</script>

<asp:Panel ID="mainPanel" runat="server">
    <table width="100%">
        <tr>
            <td style="width:54%">
                <asp:Panel ID="panelGeneral" runat="server" GroupingText="General Info">
                    <table width="100%">
                        <tr>
                            <td style="text-align:right; vertical-align:top; width:80px">
                                <asp:Label ID="label1" runat="server" Text="Purchase#:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align:left; vertical-align:top">
                                <asp:TextBox ID="txtPurchaseOrderNo" Width="100px" runat="server" ReadOnly="true"></asp:TextBox>
                            </td>
                            <td style="text-align:right; vertical-align:top; width:100px">
                                <asp:Label ID="label2" runat="server" Text="User:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align:left; vertical-align:top">
                                <asp:Label ID="lblUser" runat="server" Text=" class="labelMessage"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align:right; vertical-align:top">
                                <asp:Label ID="label3" runat="server" Text="Date:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align:left; vertical-align:top">
                                <asp:TextBox ID="txtDate" runat="server" Width="100px"></asp:TextBox>
                                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate">
                                </cc1:CalendarExtender>
                                <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDate" class="requiredField"
                                    Text="required" ErrorMessage="required"></asp:RequiredFieldValidator>
                            </td>
                            
                            <td style="text-align:right; vertical-align:top">
                                <asp:Label ID="label4" runat="server" Text="Supllier:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align:left; vertical-align:top">
                                <asp:DropDownList ID="ddlSupplier" runat="server"></asp:DropDownList>
                                <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="RequiredFieldValidator2" runat="server" ControlToValidate="ddlSupplier" class="requiredField"
                                    Text="required" ErrorMessage="required"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
            <td>
                <asp:Panel ID="panelPayment" runat="server" GroupingText="Payment" >
                    <table width="100%">
                        <tr>
                            <td style="text-align: right; vertical-align: top; width:80px">
                                <asp:Label ID="label6" runat="server" Text="Total Amt:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top; ">
                                <asp:Label ID="lblTotalAmt" runat="server" Text="" class="labelMessage"></asp:Label>
                                <asp:UpdatePanel ID="updateTotalLabel" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate> 
                                        <asp:TextBox ReadOnly="true" Width="100px" ID="txtTotalAmt" runat="server" Text=""></asp:TextBox>
                                    </ContentTemplate>
                                 </asp:UpdatePanel>
                            </td>
                            <td style="text-align: right; vertical-align: top;width:80px">    
                                <asp:Label ID="Label9" runat="server" Text="Invoice#:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top;">
                                <asp:TextBox onfocus='this.select();'  Width="100px" ID="txtInvoiceNo" runat="server" Text=""></asp:TextBox>
                                <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtInvoiceNo" class="requiredField"
                                    Text="required" ErrorMessage="required"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right; vertical-align: top">
                                <asp:Label ID="label10" runat="server" Text="Paid Amt:" class="labelMessage"></asp:Label>
                            </td>
                            <td >
                                <asp:TextBox  onfocus='this.select();' runat="server" ID="txtPayAmt" Width="100px"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="txtPayAmt" FilterType="Numbers,Custom" ValidChars="." runat="server">
                                </cc1:FilteredTextBoxExtender>
                            </td>
                            <td style="text-align: right; vertical-align: top">
                                <asp:Label ID="label8" runat="server" Text="Method:" class="labelMessage"></asp:Label>
                            </td>
                            <td >
                                <asp:DropDownList ID="ddlPaymentMethod" runat="server"></asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
                <div >
                    <table width="100%" class="toolbar"> 
                        <tr>
                            <td style='vertical-align:middle'>
                                <asp:LinkButton class="tbbutton" ID="btnEditProd" runat="server" OnClientClick=" return onEditProduct();" OnClick="btnEditProd_Click" >
                                    <asp:Image ID="image1" runat="server" ImageUrl="~/Images/Edit.gif" /><asp:Label ID="label12" runat="server" Text="Edit"></asp:Label>
                                </asp:LinkButton> 
                                <asp:LinkButton class="tbbutton" ID="btnDeleteProd" runat="server" OnClientClick="return onRemoveProduct();" OnClick="btnRemoveProd_Click" >
                                    <asp:Image ID="image2" runat="server" ImageUrl="~/Images/Delete.gif" /><asp:Label ID="label13" runat="server" Text="Delete" ></asp:Label>
                                </asp:LinkButton> 
                            </td>
                        </tr>
                    </table>
                    
                </div>
                <asp:UpdatePanel ID="updateGrid" runat="server" UpdateMode="Conditional">
                    <ContentTemplate> 
                        <uc:PurchaseOrderDetails Width="100%" ID="purchaseOrderDetails" runat="server" AllowSelecting="true" AllowSorting="true" AllowPaging="false" />
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div style="height:10px">&nbsp;</div>
                <div style="text-align:center">
                    <div style="float:right">
                        <asp:CheckBox ID="chkAutoPrint" runat="server" Text="Auto print after Submit" Checked="true" />
                    </div>
                    <asp:Button ID="btnNewPO" runat="server" Text="New Order" OnClick="btnNewPO_OnClick" />
                    <asp:Button ValidationGroup="Save" ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_OnClick" />
                    <asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_OnClick" />
                    <asp:HiddenField ID="hidNewPurchaseID" runat="server" />
                </div>
            </td>
        </tr>
    </table>
</asp:Panel>